package com.swak.consistency.reliablemsg.storage;

import java.util.Date;
import java.util.List;

import com.swak.consistency.reliablemsg.context.ReliableMsgLog;
import com.swak.consistency.reliablemsg.domain.ReliableMsgDTO;
import com.swak.entity.Page;
import com.swak.entity.Parameters;
import com.swak.persistence.QueryCondition;

/**
 * 可靠消息存储
 * 
 * @author lifeng
 * @date 2021年2月3日 下午2:22:05
 */
public interface ReliableMsgLogStorage {

	/**
	 * 获取消息
	 * 
	 * @param reliableMsg
	 */
	ReliableMsgLog get(Long msgId);

	/**
	 * 确认消息
	 * 
	 * @param reliableMsg
	 */
	void create(ReliableMsgLog reliableMsg);

	/**
	 * 确认消息
	 * 
	 * @param reliableMsg
	 */
	void updatePhase(ReliableMsgLog reliableMsg);

	/**
	 * 取消消息
	 * 
	 * @param reliableMsg
	 */
	void remove(ReliableMsgLog reliableMsg);

	/**
	 * 失败的事务日志
	 * 
	 * @return
	 */
	List<ReliableMsgLog> queryRetryMessage(Date delay);

	/**
	 * 重试失败
	 * 
	 * @param transId
	 * @return
	 */
	void retry(ReliableMsgLog reliableMsg, int maxTimes);

	/**
	 * 可靠消息分页
	 * 
	 * @param query
	 * @param param
	 * @return
	 */
	Page<ReliableMsgDTO> logPage(QueryCondition query, Parameters param);

	/**
	 * 失败消息分页
	 * 
	 * @param query
	 * @param param
	 * @return
	 */
	Page<ReliableMsgDTO> failPage(QueryCondition query, Parameters param);
}